//
//  RecommendCollectionViewCell.m
//  MarianasTrench
//
//  Created by 付建国 on 16/3/17.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "RecommendCollectionViewCell.h"

@interface RecommendCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageV;

@property (nonatomic, strong) UILabel *titleL;

@property (nonatomic, strong) UILabel *comeL;

@end

@implementation RecommendCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
// 重写setter方法
- (void)setModel:(ListModel *)model{
    _model = model;
    [self fuzhi];
}
- (void)fuzhi{
//    [self.imageV sd_setImageWithURL:[NSURL URLWithString:_model.coverLarge]];
    dispatch_async(dispatch_get_main_queue(), ^{
        
        [self.imageV HANDLEIMAGE(_model.coverLarge)];
    });
    
    self.titleL.text = _model.trackTitle;
    self.titleL.numberOfLines = 10;
    self.titleL.font = [UIFont systemFontOfSize:12];
    
    self.comeL.text = _model.title;
    self.comeL.font = [UIFont systemFontOfSize:10];
    self.comeL.textColor = [UIColor grayColor];
}


- (void)createSubViews{
    self.imageV = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageV];
    
    self.titleL = [[UILabel alloc] init];
    [self.contentView addSubview:_titleL];
    
    self.comeL = [[UILabel alloc] init];
    [self.contentView addSubview:_comeL];
}
// 布局
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    [super applyLayoutAttributes:layoutAttributes];
    self.imageV.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height - 40);
    
    self.titleL.frame = CGRectMake(0, layoutAttributes.frame.size.height - 40, layoutAttributes.frame.size.width, 30);
    
    self.comeL.frame = CGRectMake(0, layoutAttributes.frame.size.height - 10, layoutAttributes.frame.size.width, 10);
}












@end
